﻿// Copyright (c) 2023 raoyutian Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
using System.Runtime.InteropServices;

//说明：ClasParameter类的属性定义顺序不可随便更改，需要与PaddleClas C++代码中的ClasParameter顺序一致

namespace PaddleClasSharp
{
    /// <summary>
    /// 图像分类参数对象
    /// </summary>
    [StructLayout(LayoutKind.Sequential, Pack = 1)]
    public class ClasParameter
    {
        /// <summary>
        /// 是否使用GPU；默认false
        /// </summary>
        [field: MarshalAs(UnmanagedType.I1)]
        public bool use_gpu { get; set; } = false;
        /// <summary>
        /// GPU id，使用GPU时有效；默认0;
        /// </summary>
        public int gpu_id { get; set; } = 0;
       /// <summary>
       /// 显存大小设置，单位M
       /// </summary>
        public int gpu_mem { get; set; } = 4000;
        /// <summary>
        /// 使用启用mkldnn加速
        /// </summary>
        [field: MarshalAs(UnmanagedType.I1)]
        public bool enable_mkldnn { get; set; } = false;
        /// <summary>
        /// 使用启用mkldnn加速
        /// </summary>
        public int cpu_num_threads { get; set; } = 10;
        [field: MarshalAs(UnmanagedType.I1)]
        public bool enable_benchmark { get; set; } = true;
        [field: MarshalAs(UnmanagedType.I1)]
        public bool use_fp16 { get; set; } = false;
        [field: MarshalAs(UnmanagedType.I1)]
        public bool ir_optim = true;
        [field: MarshalAs(UnmanagedType.I1)]
        public bool use_tensorrt { get; set; } = false;
        public int rec_resize_size { get; set; } = 224;
        public float rec_scale { get; set; } = 0.00392157f;
        public int batch_size { get; set; } = 1;
        [field: MarshalAs(UnmanagedType.I1)]
        public bool enable_profile { get; set; } = false;
        public float rec_nms_thresold { get; set; } = 0.05f;
        public float threshold { get; set; } = 0.2f;
        public int max_det_results { get; set; } = 5;
        //IndexProcess
        public int embedding_size { get; set; } = 512;
        public int index_batch_size { get; set; } = 32;
        public int return_k { get; set; } = 5;
        public float score_thres { get; set; } = 0.5f;
    }

    /// <summary>
    /// 模型配置对象
    /// </summary>
    public class ModelConfig
    {
        /// <summary>
        /// det_model_dir模型路径
        /// </summary>
        public string det_infer { get; set; }
        /// <summary>
        /// rec_model_dir模型路径
        /// </summary>
        public string rec_infer { get; set; }
        /// <summary>
        ///index_dir模型路径
        /// </summary>
        public string index_dir { get; set; }
        /// <summary>
        ///yaml文件路径
        /// </summary>
        public string yaml_file { get; set; }

        
    }
}


